#ifndef PAGEHUMITURE_H
#define PAGEHUMITURE_H

#include <QWidget>
#include <QtGui>
#include <QTimer>
#include <QtSerialPort/QSerialPort>
#include <fcntl.h>
//#include <sys/ioctl.h>
#include <sys/stat.h>
#include <QFile>
#include <unistd.h>

class widgetBasewave : public QWidget
{
    Q_OBJECT
public:
    explicit widgetBasewave(QWidget *parent = 0);

public:
    QByteArray sendBuf;
    QString sendTcpBuf;

    typedef QPushButton myButton;

//    double CIA;//系数IA
//    double CIB;//系数IB
//    double CIC;//系数IC
//-----频率
    QLineEdit *Frequency;

//------百分比
    QLineEdit *lineUAn;
    QLineEdit *lineIAn;
    QLineEdit *lineUBn;
    QLineEdit *lineIBn;
    QLineEdit *lineUCn;
    QLineEdit *lineICn;

//-------相位
    QLineEdit *LineUA;
    QLineEdit *LineUB;
    QLineEdit *LineUC;
    QLineEdit *LineIA;
    QLineEdit *LineIB;
    QLineEdit *LineIC;

    QComboBox *boxTest;
    QComboBox *boxVoltage;
    QComboBox *boxCurrent;

    QList <QPushButton*> funcBtnUList;
    QList <QPushButton*> funcBtnPList;
    QList <QPushButton*> funcBtnIList;

private:
    int Test_style;
    QFont ft;
    int Timecount;
    bool TestStyle; //true:start;false:stop
    QWidget *widgetInfo;
    QLabel *labInfo;
    QTimer *plotTimer;

    void setDataStyle(QLabel *);

//*********************************************************
private:
    QByteArray getdata;

    QLabel *labPowerA;
    QLabel *labPowerB;
    QLabel *labPowerC;

    QLabel *labEffective_VoltageA;
    QLabel *labEffective_VoltageB;
    QLabel *labEffective_VoltageC;

    QLabel *labPhase_voltageA;
    QLabel *labPhase_voltageB;
    QLabel *labPhase_voltageC;

    QLabel *labEffective_CurrentA;
    QLabel *labEffective_CurrentB;
    QLabel *labEffective_CurrentC;

    QLabel *labPhase_CurrentA;
    QLabel *labPhase_CurrentB;
    QLabel *labPhase_CurrentC;

    QLabel *txt_PhaseAB;
    QLabel *txt_PhaseAC;

    QWidget *paintArea;

    QComboBox *cboVoltageUA;
    QComboBox *cboVoltageUB;
    QComboBox *cboVoltageUC;

    QComboBox *cboCurrentIA;
    QComboBox *cboCurrentIB;
    QComboBox *cboCurrentIC;


    QComboBox *boxPhase;

    QLineEdit *lineSetPhaseAB;
    QLineEdit *lineSetPhaseAC;

    QLineEdit *linePowerA;
    QLineEdit *linePowerB;
    QLineEdit *linePowerC;

    QLabel *labRangeUA_dw;
    QLabel *labRangeUB_dw;
    QLabel *labRangeUC_dw;
    QLabel *labRangeIA_dw;
    QLabel *labRangeIB_dw;
    QLabel *labRangeIC_dw;

    QLineEdit *labRulte_A;
    QLineEdit *labRulte_B;
    QLineEdit *labRulte_C;
    QLineEdit *labRulte_AB;
    QLineEdit *labRulte_AC;


    myButton *btnBack;
    myButton *btnStart;
    myButton *btnStop;

    myButton *radio5L;
    myButton *radio8L;
    myButton *radio1;
    myButton *radio5C;
    myButton *radio8C;

    QLineEdit *lineActive;

//*********************************************************
    QPushButton *btnU1, *btnU2, *btnU3, *btnU4, *btnU5,*btnU6;
    QPushButton *btnP1, *btnP2, *btnP3, *btnP4, *btnP5;
    QPushButton *btnI1, *btnI2, *btnI3, *btnI4, *btnI5, *btnI6, *btnI7;

signals:
    void cmdSend();
    void TcpSend();

public slots:
    void recvResult(QByteArray redata);
    void widgetInfoHide(){widgetInfo->hide();}
    void startTest();
    void init();
    void dataclear();
    QString Cos_Calculation(int,QString);
    QString change_data(int,QString);
    void Line_change(QString);
//    QByteArray* DatatoHex(int,int);
    void DatatoHex(int,int);
    void btnStartUnLock(){btnStart->setEnabled(true);}
    void btnStopUnLock(){btnStop->setEnabled(true);}
    void boxChangeTo(int);
    void sendStopData();
    void showTcpData(QString,QString);
    void resolveTCPData(QString);

    void addOrder577(QLineEdit *line);
    void addOrder100(QLineEdit *line);
    void addOrder100_change(double);//先计算，在*100发送

    void UQuickSet(QString str);
    void IQuickSet(QString str);
    void PQuickSet(QString str);
};


#endif // PAGEHUMITURE_H
